package com.wtf.dsp.admin.filter;

import cn.hutool.core.util.IdUtil;
import com.wtf.dsp.admin.util.MdcUtil;
import org.apache.logging.log4j.ThreadContext;
import org.slf4j.MDC;

import javax.servlet.*;
import java.io.IOException;

/**
 * ClassName: LogMDCFilter
 * Description:
 * date: 2024/9/11 11:04
 *
 * @author linhuanyou
 * @version 1.0
 */
public class LogMdcFilter implements Filter{

    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        MdcUtil.putLogMid();
        try {
            filterChain.doFilter(servletRequest, servletResponse);
        } finally {
            MdcUtil.removeLogMid();
        }
    }
}
